var $ = getApp(), methods = require("../methods.js");
Page(Object.assign({}, methods, {
	data: {
		id:'',
		status:1,
	},
	_onLoad:function(){
		var that = this
		var id = '';
		if(that.options && that.options.id){
			id = that.options.id;
		}
		$.get('businessht/hexiaouseredit',{id:id},function(res){
			if(res.info && res.info.id){
				res.status = res.info.status;
				res.id = res.info.id;
			}
			that.setData(res)
		})
	},
	confirm:function(e){
		var that = this
		var formdata = e.detail.value;
		var name = formdata.name;
		var uname = formdata.uname;
		var pwd = formdata.pwd;
		var st = that.data.status;
		if(name == ''){
			$.error('请输入核销员名称');return;
		}
		if(uname == ''){
			$.error('请输入登录账号');return;
		}
		if(pwd == ''){
			$.error('请输入登录密码');return;
		}
		$.post('businessht/hexiaouseredit',{id:that.data.id,name:name,uname:uname,pwd:pwd,status:st},function(res){
			if(res.status == 1){
				$.success(res.msg);
				setTimeout(function(){
					$.goto('hexiaouser','redirect');
				},1000);
			}else{
				$.error(res.msg);
			}
		},'提交中');
	},
	statusChange:function(e){
		this.setData({status:e.detail.value})
	},
}))